﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace CTTest.Common
{
    class TestUtil
    {
        internal static string WrapperObject(object v)
        {
            Assert.IsNotNull(v, "object v");

            StringBuilder sb = new StringBuilder();

            sb.AppendFormat("\tTarget type is {0}", v.GetType().FullName);
            sb.AppendLine();

            // bypass value type and string type
            if (v is ValueType || v is System.String)
            {
                return sb.ToString();
            }

            foreach (var p in v.GetType().GetProperties())
            {
                sb.AppendFormat("\t{0}={1}, {2}", p.Name, p.GetValue(v, null), p.PropertyType.FullName);
                sb.AppendLine();
            }

            return sb.ToString();
        }
    }
}
